﻿using Application.AppService.CFTKAppService;
using Application.AppService.CMAppService;
using Application.AppService.CMKAppService;
using AutoMapper;
using Domain.Entity;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers.Customization_Settings_客户化设置_.Human_resource_file_management_人力资源档案管理_
{
    public class CMController : Controller
    {
        private readonly ICMAppService cmAppService;
        private readonly IMapper mapper;

        public CMController(ICMAppService cmAppService, IMapper mapper)
        {
            this.cmAppService = cmAppService;
            this.mapper = mapper;
        }

        public IActionResult Index()
        {
            return View();
        }
        [HttpGet("GetCM")]
        public async Task<IActionResult> GetCM()
        {
            List<CM> cms = await cmAppService.GetCMAsync();
            return Json(cms);
        }
		[HttpPost("DeleteCM")]
		public async Task<IActionResult> DeleteCM(int id)
		{
			bool i = await cmAppService.DeleteCMAsync(id);
			return Json(i);
		}
		[HttpPost("AddCM")]
		public async Task<IActionResult> AddCM(CM cm)
		{
			bool i = await cmAppService.AddCMAsync(cm);
			return Json(i);
		}
		[HttpGet("GetCMById/{id}")]
		public async Task<IActionResult> GetCMById(string id)
		{
			List<CM> cm = await cmAppService.GetCMAsyncById(id);
			return Json(cm);
		}
		[HttpPost("GetCMSById")]
		public async Task<IActionResult> GetCMSById(string id)
		{
			CM cm = await cmAppService.GetCMSAsyncById(id);
			return Json(cm);
		}
	}
}
